import { MotaInterface } from '@/mota';
import BuildUtils from '@/mota/utils/BuildUtils';

export default class BuildMap implements MotaInterface {

	public build: BuildUtils;

	public ZIndex: number = 5;

	public constructor(build: BuildUtils) {
		this.build = build;
	}

	public InView(): boolean {
		const { build } = this;
		const { Mota } = build;
		const { onBuild } = Mota;
		return onBuild;
	}

	public Draw: MotaInterface["Draw"] = (draw) => {
		const { build: { map: { unit } } } = this;
		const { _2d } = draw;

		if (!this.InView()) { return; }

		_2d.save();

		draw.translate(4, 0);

		unit.forEach((unit) => draw.DrawUnti(unit));

		_2d.restore();
	}
}
